using System;
using System.Collections.Generic;
using System.Text;

namespace GoogleNet
{
    /// <summary>
    /// A Style defines an addressable style group that can be referenced by StyleMaps and Features. 
    /// Styles affect how Geometry is presented in the 3D viewer and how Features appear in the 
    /// Places panel of the List view. Shared styles are collected in a Document and must have 
    /// an id defined for them so that they can be referenced by the individual Features that use them. 
    /// <remarks>Use an id to refer to the style from a styleUrl. </remarks>
    /// </summary>
    public class KmlStyle : KmlStyleSelector
    {
        private string tagName = "Style";

        #region LineStyle
        private KmlLineStyle lineStyle;

        /// <summary>
        /// Gets or sets the line style.
        /// </summary>
        /// <value>The line style.</value>
        public KmlLineStyle LineStyle
        {
            get { return lineStyle; }
            set { lineStyle = value; }
        } 
        #endregion

        #region IconStyle
        private KmlIconStyle iconStyle;

        /// <summary>
        /// Gets or sets the icon style.
        /// </summary>
        /// <value>The icon style.</value>
        public KmlIconStyle IconStyle
        {
            get { return iconStyle; }
            set { iconStyle = value; }
        } 
        #endregion

        #region BaloonStyle
        private KmlBaloonStyle baloonStyle;

        /// <summary>
        /// Gets or sets the baloon style.
        /// </summary>
        /// <value>The baloon style.</value>
        public KmlBaloonStyle BaloonStyle
        {
            get { return baloonStyle; }
            set { baloonStyle = value; }
        } 
        #endregion

        #region LabelStyle
        private KmlLabelStyle labelStyle;

        /// <summary>
        /// Gets or sets the label style.
        /// </summary>
        /// <value>The label style.</value>
        public KmlLabelStyle LabelStyle
        {
            get { return labelStyle; }
            set { labelStyle = value; }
        } 
        #endregion

        #region ListStyle
        private KmlListStyle listStyle;

        /// <summary>
        /// Gets or sets the list style.
        /// </summary>
        /// <value>The list style.</value>
        public KmlListStyle ListStyle
        {
            get { return listStyle; }
            set { listStyle = value; }
        } 
        #endregion

        #region PolyStyle
        private KmlPolyStyle polyStyle;

        /// <summary>
        /// Gets or sets the polygons style.
        /// </summary>
        /// <value>The polygons style.</value>
        public KmlPolyStyle PolyStyle
        {
            get { return polyStyle; }
            set { polyStyle = value; }
        } 
        #endregion

        #region IKmlElement Members

        /// <summary>
        /// Name of the KML tag for this specific element.
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        public override string TagName
        {
            get { return tagName; }
        }

        #endregion

        #region IKmlGenerator Members

        /// <summary>
        /// Generates the KML for this element including its child elements.
        /// </summary>
        /// <param name="writer">The XML writer that will be used to generate the KML.</param>
        public override void GenerateKml(System.Xml.XmlTextWriter writer)
        {
            writer.WriteStartElement(tagName);
            base.GenerateKml(writer);

            if (lineStyle != null)
                lineStyle.GenerateKml(writer);

            if (iconStyle != null)
                iconStyle.GenerateKml(writer);

            if (baloonStyle != null)
                baloonStyle.GenerateKml(writer);

            if(labelStyle != null)
                labelStyle.GenerateKml(writer);

            if (listStyle != null)
                listStyle.GenerateKml(writer);

            if (polyStyle != null)
                polyStyle.GenerateKml(writer);

            writer.WriteEndElement();

        }

        #endregion
    }
}
